<?php

class SellController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }
    
    public function registerAction()
    {
        $this->_helper->viewRenderer->setNoRender(TRUE);
        $this->_helper->layout()->disableLayout();
        $request = $this->getRequest();

        // Common attributes
        $category = $request->getParam('category');
        $type_id = $request->getParam('type');
        $status_id = $request->getParam('status');
        $city = $request->getParam('city');
        $count = $request->getParam('count');
        $location = $request->getParam('location');
        $bhk = $request->getParam('bhk');
        $rate = $request->getParam('rate');
        $size = $request->getParam('size');
        $state = $request->getParam('state');
        $summary = $request->getParam('summary');
        
        $fname = $request->getParam('fname');
        $mname = $request->getParam('mname');
        $lname = $request->getParam('lname');
        $owner = $fname.' '.$mname.' '.$lname;
        $owner_address = $request->getParam('owner_address');
        $owner_contact_no = $request->getParam('owner_contact_no');
            
        $estate = new Reale_Model_Estate_Property();
        $estate->setOwner($owner)
                ->setOwner_address($owner_address)
                ->setOwner_contact_no($owner_contact_no);
        
        
        $estate->setCategory_id($category)
                ->setType_id($type_id)
                ->setStatus_id($status_id)
                ->setCity($city)
                ->setCount($count)
                ->setLocation($location)
                ->setBhk($bhk)
                ->setRate($rate)
                ->setSize($size)
                ->setState($state)
                ->setSummary($summary);
        
        $oper = $request->getParam('oper');
        switch ($oper) {
            case 'add':
            case 'mod':
                if ($estate->save()) {
                    echo 'Submit successful.';
                    return;
                }
                
            break;
            case 'del':
            break;
            default:
                throw new Zend_Exception('"'.$oper.'" is unknown operation.', Zend_Log::ERR);
            break;
        }
        throw new Zend_Exception('Operation on property not successfull.', Zend_Log::ERR);
    }
    
        
}

